package cn.lingyangwl.framework.knife4j.micro;

import cn.lingyangwl.framework.knife4j.micro.servlet.Knife4jConfig;
import cn.lingyangwl.framework.knife4j.micro.servlet.PcKnife4jApiInfoProperties;
import cn.lingyangwl.framework.knife4j.micro.reactive.PcKnife4jProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

import javax.annotation.PostConstruct;

/**
 * @author shenguangyang
 */
@AutoConfiguration
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
@EnableConfigurationProperties({PcKnife4jApiInfoProperties.class, PcKnife4jProperties.class})
@ImportAutoConfiguration({Knife4jConfig.class})
public class LyKnife4jServletAutoConfiguration {
    private static final Logger log = LoggerFactory.getLogger(LyKnife4jServletAutoConfiguration.class);
    @Value("${server.port:8080}")
    private Integer port;

    @PostConstruct
    public void init() {
        log.info("init {}", this.getClass().getName());
        log.info("获取swagger json数据接口: [http://127.0.0.1:{}/{} , http://127.0.0.1:{}/{}]",
                port, "v2/api-docs", port, "v3/api-docs");
    }
}
